import React from "react"

import http from "../../helper/request"

const useApi = () => {
	const { useState } = React
	const [loading, setLoading] = useState(false)

	async function generalHttp<T>(url: string, body: object | undefined) {
		setLoading(true)
		const ret = await http.post<T>(url, body)
		setLoading(false)
		return ret
	}
	// 俱乐部申请列表
	const clubManageClubAuditList = async (body: object | undefined) => {
		const ret = await generalHttp("/clubAudit/clubAuditList", body)
		return ret
	}
	// 俱乐部列表
	const clubManagerList = async (body: object | undefined) => {
		const ret = await generalHttp("/club/list", body)
		return ret
	}
	// 审批状态
	const clubManageAudit = async (body: object | undefined) => {
		const ret = await generalHttp("/clubAudit/audit", body)
		return ret
	}
	return {
		clubManageAudit,
		clubManagerList,
		clubManageClubAuditList,
		generalHttp,
		loading
	}
}

export default useApi
